<!DOCTYPE html>
<html>

<head>
  <meta charset="UTF-8">
  <!--引入Vue-->
  <script type="text/javascript" src="../js/vue.js"></script>
  <title></title>
</head>

<body>
  <!--准备好一个容器-->
  <div class="root">
    <ul>
      <button @click.once="add">加个老刘</button>
      <br><br>
      <li v-for="p in persons" :key="p.id">
        {{p.name}}-{{p.age}}
        <input type="text">
      </li>
    </ul>
  </div>

  <script type="text/javascript">
    Vue.config.productionTip = false;

    new Vue({
      el: '.root',
      data: {
        persons: [
          { id: '001', name: '张三', age: 18 },
          { id: '002', name: '李四', age: 19 },
          { id: '003', name: '王二麻', age: 20 }
        ]
      },
      methods: {
        add(){
          const p={id:'004',name:"老牛",age:40}
          this.persons.unshift(p)
        }
      },
    })
  </script>
</body>

</html>